public class OneEditAway {

    public static void main(String[] args) {
        OneEditAway oneEditAway = new OneEditAway();
        System.out.println(oneEditAway.oneEditAway("pale", "ple"));
        StringBuffer stringBuffer = new StringBuffer();
    }


    public boolean oneEditAway(String first, String second) {
        int n = first.length();
        int m = second.length();
        if (n > m) return oneEditAway(second, first);
        if (m - n == 1) {
            int count = 0;
            for (int i = 0; i < n; i++) {
                if (count == 0 && first.charAt(i) != second.charAt(i)) {
                    count++;
                }
                if (count == 1 && first.charAt(i) != second.charAt(i + 1)) {
                    return false;
                }
            }
            return true;
        } else if (m == n) {
            int count = 0;
            for (int i = 0; i < n; i++) {
                if (first.charAt(i) != second.charAt(i)) {
                    count++;
                }
                if (count > 1) return false;
            }
            return true;
        } else return false;
    }
}
